package com.tj.jinzao.presenter;

import com.tj.jinzao.api.SubscriberCallBack;
import com.tj.jinzao.base.BasePresenter;
import com.tj.jinzao.callback.IJobView;
import com.tj.jinzao.model.Occupation;
import com.tj.jinzao.model.ResultResponse;

import java.util.List;

/**
 * 岗位职称
 * Created by wjy 2018/12/10.
 */
public class LabelOccupationPresenter extends BasePresenter<IJobView<List<Occupation.ItemsBean>>> {

    private List<Occupation> mList;

    public LabelOccupationPresenter(IJobView<List<Occupation.ItemsBean>> view) {
        super(view);
    }

    public void getOccupationListByLabel(int index) {
        if (mView != null && mList!= null && mList.size() > index) mView.onRequestSuccess(mList.get(index).getItems());
    }

    public void getOccupations() {
        addSubscription(mApiService.getOccupationList()
                , new SubscriberCallBack<List<Occupation>>(mView.getContext()) {
                    @Override
                    protected void onSuccess(List<Occupation> list) {
                        mList = list;
                        if(mView != null) mView.onLabelList(list);
                    }

                    @Override
                    protected void onFailure(ResultResponse response) {
                        if (mView != null) mView.onRequestError(response.getMessage());
                    }

                    @Override
                    protected boolean isShowProgress() {
                        return true;
                    }
                });
    }


}
